package yifeng.program;

import yifeng.program.utils.Utils;

public class BubbleSort {
	
	
	public static void main(String[] args){
		int[] a = Utils.createIntArray(10, 1, 100);
		
		printArray(a);
		
		
		int i = 0, j = 0;
		for(;i < a.length; i++)
			for(j = 0; j < a.length-i-1; j++){
				if(a[j] > a[j+1])
					Utils.swap(a, j, j+1);
			}
		
		System.out.println("After sorting:");
		printArray(a);
		
	}
	
	
	



	private static void printArray(int[] a){
		int i = 0;
		for(; i < a.length-1; i++){
			System.out.print(a[i] + "-");
		}
		System.out.println(a[i]);
	}
}
